<!DOCTYPE html>
<html lang="ch" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="inc :: header('小区管理')" />
</head>
<body>
    <div shiro:hasPermission="ac:add">
        <a class="layui-btn layui-btn-xs layui-btn-danger">新增</a>
    </div>
    <hr>
    <div shiro:hasPermission="ac:edit">
        <a class="layui-btn layui-btn-xs">编辑</a>
    </div>

    <table id="treeTab" lay-filter="treeTab"></table>
    <script>
        layui.config({
            base:'/js/'
        }).use(['treeTable','layer','util'],function () {
            var treeTable = layui.treeTable;
            var util = layui.util;


            //渲染树表格
            treeTable.render({
                elem:'#treeTab',
                url:'/ac/findSelect',
                height:'full-0',
                toolbar:'default',
                tree:{
                    iconIndex:1,
                    isPidData: true,
                    idName: 'id',
                    pidName:'parentId'
                },
                cols:[
                    [
                        {type:'checkbox'},
                        {field:'name',title:'区域名称',width:250},
                        {field:'parentId',title:'父编号',width:150},
                       // {fixed:'right',title:'操作',width:150}
                    ]
                ]
            });
            //监听工具条按钮
            treeTable.on('toolbar(treeTab)',function (obj) {
                switch (obj.event) {
                    case 'add':
                        layer.open({
                            title:'新增区域',
                            type:2,
                            maxmix:true,
                            area:['400px','300px'],
                            anim:3,
                            btn:['确定保存','取消关闭'],
                            content:'/ac/addEdit'
                        });
                        break;
                }
            });
        });
    </script>

</body>
</html>